package com.gao.ranklist.controller;

import com.gao.ranklist.service.BaiduHotSearchSpiderService;
import com.gao.ranklist.service.HotSearchRanklistService;
import com.gao.ranklist.service.impl.HotSearchRanklistServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 爬虫获取百度热搜数据
 * 数据存入到 redis 中，用作模拟排行榜数据
 */
@RestController
public class BaiduHotSearchSpiderController {

    @Autowired
    private BaiduHotSearchSpiderService service;

    @Autowired
    private HotSearchRanklistServiceImpl hotService;

    @PostMapping("init")
    public void getBaiduHotSearchData() {
        service.initData();
    }

    @PostMapping("init30")
    public void gen30HotSearchData() {
        hotService.init30DayData();
    }

    @PostMapping("initAll")
    public void initAllData() {
        hotService.autoRefreshData();
    }
}
